﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace xna_game_engine.source
{
    public class CombatText
    {
        // Members
        protected float m_fLife = 1.5f;
        protected float m_fSpeed = 1.0f;
        protected float mXOffset;
        protected string m_sString = "";
        protected bool m_bDraw = true;
        protected Color m_cColor = Color.HotPink;
        protected ContentManager m_cContent;
        protected SpriteBatch m_cSpriteBatch;
        protected TongaTimer m_cTimer;
        protected BaseCharacter m_cAttachee;
        protected Vector2 m_vPosition;

        public CombatText(BaseCharacter attach, float xOffset)
        {
            m_cAttachee = attach;
            m_cTimer = new TongaTimer(0.5);
            m_vPosition = attach.Position + new Vector2(xOffset, 0.0f);
            mXOffset = xOffset;
        }

        public void SetAttach(BaseCharacter att)
        {
            m_cAttachee = att;
        }

        public void Trigger(string text, Color color)
        {
            m_sString = text;
            m_cColor = color;
            m_cTimer.Reset();
        }

        public void Update(GameTime gt)
        {
            m_vPosition.X = m_cAttachee.Position.X + mXOffset;
            if (m_bDraw)
            {
                m_vPosition.Y -= m_fSpeed;
            }

            if (m_cTimer.Check())
            {
                m_bDraw = false;
            }

            // Update our timer too
            m_cTimer.Update(gt);
        }

        public void Draw()
        {
            if (m_bDraw)
            {
                //m_cSpriteBatch.DrawString(sf, m_sString, m_vPosition, m_cColor);
                GameSystems.Graphics.DrawText(m_sString, m_vPosition, m_cColor);
            }
        }

        public bool IsActive()
        {
            return m_bDraw;
        }
    }
}
